import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { HttpServicesProvider } from "../../providers/http-services/http-services";
import { UtilsProvider } from "../../providers/utils/utils";
import { ValidateProvider } from "../../providers/validate/validate";
import { ConfigProvider } from "../../providers/config/config";
import { StorageProvider } from "../../providers/storage/storage";

/**
 * Generated class for the ReBuyDetailPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage({
  segment: 're-buy/detail/:id',
  defaultHistory: ['ReBuyListPage', 'HomePage']
})
@Component({
  selector: 'page-re-buy-detail',
  templateUrl: 're-buy-detail.html',
})
export class ReBuyDetailPage {
            token: string;
            amoy_id: number;
            searchParams = {};
            page=1;  
            userInfo = {};
            dataInfo = {};
            tasks = [];
            constructor(
              public navCtrl: NavController, 
              public httpService: HttpServicesProvider,
              public config: ConfigProvider,
              public validate: ValidateProvider,
              public util: UtilsProvider,
              public storage: StorageProvider,
              public navParams: NavParams) {
            }

            ionViewDidLoad() {
              this.token = this.config.getToken();
              this.amoy_id = this.navParams.get('id');
              this.userInfo = JSON.parse(this.storage.get('userInfo'));
              this.getData();
              this.getData()
            }
              /**
           * 页面加载获取数据
           * */
          getData() {
            //获取任务信息列表
            let params = {
              // token: this.token,
              re_buy_id:this.amoy_id,
            };
            Object.assign(params, this.searchParams);

            let loading = this.util.loading();
            loading.show();
            this.httpService.requestPostData('/mul_mission/re_buy_info', params, response => {
              loading.close()
              this.page++
              if (response['error'] == 200) {
                this.dataInfo = response['data']['re_buy'];
                //全部数据
              } else {
                this.util.presentAlert(response.message);
              }
            });
          }

}
